import Vue from 'vue'

import App from './App.vue'
import store from './store'      //状态管理
import router from './router'   //路由


/*解决Vue-Router版本到到3.1.0及以上之后，页面在跳转路由控制台会报Uncaught (in promise)的问题*/
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
/*解决Vue-Router版本到到3.1.0及以上之后，页面在跳转路由控制台会报Uncaught (in promise)的问题*/

/*全局注册SvgIcon*/
import './icons' // icon

//全局样式
import '@/styles/index.scss' // global css
import '@/styles/element-variablesBlue.scss' //主题色样式

import ElementUI from 'element-ui'

//引入basp的包
//考虑到i18n为公共模块,如果当前项目需要国际化，则开发人员可以考虑合并和调整目录结构
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
let lang
if (window.sessionStorage.getItem('lang')) {
	lang = window.sessionStorage.getItem('lang')
}else {
	window.sessionStorage.setItem('lang','zh-CN')
	lang = 'zh-CN'
}
import LangZh from '@/views/basp/common/i18n/zh'
import LangEn from '@/views/basp/common/i18n/en'
//basp模块需要的公共方法
import VueMethod from '@/views/basp/common/method.vue.plugin.js'
Vue.use(VueMethod)
import VueAxiosExt from '@/views/basp/common/axiosExt.vue.plugin'
Vue.use(VueAxiosExt)
const i18n = new VueI18n({
    locale: lang,  // 语言标识
    messages: {
        'zh-CN': LangZh,
        'en': LangEn
    }
})
Vue.use(ElementUI, {
    i18n: (key, value) => i18n.t(key, value)
})

import './permission' // permission control

Vue.config.productionTip = false

import request from './utils/request.js'
Vue.prototype.$request = request

new Vue({
  router,
  store,
  render: h => h(App),
  i18n
}).$mount('#app')
